<template>
  <div class="component-contractList">
    <div class="component-mainHeader">
      <div class="top">
        <div class="topleft">
          <p>
            <span class="iconfont" style="color:#1abc9a;margin-right:3px;">&#xe607;</span>合同列表
          </p>
        </div>
        <div class="topright">
          <el-button type="info" @click="reverse">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe662;</span>刷新
          </el-button>
        </div>
      </div>
    </div>
    <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick" class="tabs-header">
      <el-tab-pane :label="'框架合同（'+frameCount+'）'" name="first">
        <div class="component-searchHeader">
          <div class="search-header">
            <div class="left-title">
              <p class="left-text">
                <span class="iconfont" style="font-weight:700">&#xe63d;</span>筛选查询
              </p>
              <div class="right">
                <button @click="framePage.frameCurrentPage=1;getList()">查询</button>
              </div>
            </div>
          </div>
        </div>

        <div class="component-search-box">
          <el-form :inline="true" :model="frameSearch" class="demo-form-inline">
            <el-form-item label="输入搜索：">
              <el-input v-model="frameSearch.name" placeholder="合同名称/合同内部编号" clearable></el-input>
            </el-form-item>
            <el-form-item label="甲方类型：">
              <el-select v-model="frameSearch.first" placeholder="请选择甲方类型" clearable>
                <el-option
                  v-for="(item, index) in list1"
                  :key="index"
                  :value="item.orgId"
                  :label="item.orgName"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="项目部："
              v-show="ms_roleName == 'CenterClerk' || ms_roleName == 'CenterDeputy' || ms_roleName == 'CenterFinanceManager' || ms_roleName == 'CenterBOSS'">
              <el-select v-model="frameSearch.beOrg" placeholder="请选择项目部" clearable>
                <el-option
                  v-for="(item, index) in list2"
                  :key="index"
                  :value="item.orgId"
                  :label="item.orgName"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>

        <div class="component-listHeader">
          <div class="search-header">
            <div class="left-title">
              <p class="left-text">
                <span class="iconfont">&#xe61e;</span>
                合同列表
              </p>
              <div class="right">
                <button v-show="ms_roleName == 'ProjectClerk'" @click="add1">添加合同</button>
              </div>
            </div>
          </div>
        </div>
        <div class="table">
          <el-table
            ref="multipleTable"
            :data="frameInfo"
            tooltip-effect="dark"
            style="width: 1100px;margin:0 auto"
            border
          >
            <el-table-column label="框架合同编号" align="center" width="110" prop="conOuterno"></el-table-column>
            <el-table-column label="合同内部编号" align="center" width="150" prop="conInnerno"></el-table-column>
            <el-table-column label="合同名称" align="center" prop="conName"></el-table-column>
            <el-table-column label="合同金额(万元)" align="center" width="120" prop="conMoney"></el-table-column>
            <el-table-column label="甲方类型" align="center" width="120" prop="conParta"></el-table-column>
            <el-table-column label="签约时间" align="center" width="140" prop="signDate">
              <template slot-scope="scope">{{scope.row.signDate | timeFilter}}</template>
            </el-table-column>
            <el-table-column label="完工时间" align="center" width="140" prop="finishDate">
              <template slot-scope="scope">{{scope.row.finishDate | timeFilter}}</template>
            </el-table-column>
            <el-table-column label="操作" width="200" align="center">
              <template slot-scope="scope">
                <div>
                  <el-button
                    @click="handleCheck(scope.row)"
                    type="text"
                    size="small"
                    class="red"
                  >查看/编辑</el-button>
                </div>
                <div>
                  <el-button
                    v-show="ms_roleName == 'ProjectClerk'"
                    @click="handleAdd(scope.row)"
                    type="text"
                    size="small"
                    class="red"
                  >添加子合同</el-button>
                  <!-- <el-button
                    @click="handleDelete(scope.$index, scope.row)"
                    type="text"
                    size="small"
                    class="red"
                  >删除</el-button>-->
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="component-paging" v-if="frameInfo.length > 0">
          <div class="table-bottom">
            <div class="bottom-left"></div>
            <div class="paging">
              <div class="paging-left">
                <p>
                  共
                  <span>{{Math.ceil(framePage.frameRowCount/framePage.framePageSize)}}</span> 页/
                  <span>{{framePage.frameRowCount}}</span> 条数据
                </p>
              </div>
              <el-pagination
                background
                @size-change="SizeChange($event,getList,framePage.frameCurrentPage,framePage.framePageSize)"
                @current-change="CurrentChange($event,getList,framePage.frameCurrentPage,framePage.framePageSize)"
                :current-page.sync="framePage.frameCurrentPage"
                :page-sizes="[10, 20, 30]"
                :page-size.sync="framePage.framePageSize"
                layout="sizes, prev, pager, next, jumper"
                :total="framePage.frameRowCount"
              ></el-pagination>
            </div>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane :label="'虚拟合同（'+falseContractNum+'）'" name="fourth">
        <div class="component-searchHeader">
          <div class="search-header">
            <div class="left-title">
              <p class="left-text">
                <span class="iconfont" style="font-weight:700">&#xe63d;</span>筛选查询
              </p>
              <div class="right">
                <button @click="addFalseContractsList.falseCurrentPage=1;getList()">查询</button>
              </div>
            </div>
          </div>
        </div>
        <div class="component-search-box">
          <el-form :inline="true" :model="addFalseContractsList" class="demo-form-inline">
            <el-form-item label="输入搜索：">
              <el-input v-model="addFalseContractsList.name" placeholder="合同名称/合同内部编号" clearable></el-input>
            </el-form-item>
           <!-- <el-form-item label="所属框架合同：" style="width: 340px;">
              <el-select v-model="frameSearch.first" placeholder="所属框架合同" clearable>
                <el-option
                  v-for="(item, index) in list1"
                  :key="index"
                  :value="item.orgId"
                  :label="item.orgName"
                ></el-option>
              </el-select>
            </el-form-item>-->
          </el-form>
        </div>
        <div class="component-listHeader">
          <div class="search-header">
            <div class="left-title">
              <p class="left-text">
                <span class="iconfont">&#xe61e;</span>
                合同列表
              </p>
              <div class="right">
                <button v-show="ms_roleName == 'ProjectClerk'" @click="addFalseContractList">添加合同</button>
              </div>
            </div>
          </div>
        </div>
        <div class="table">
          <el-table
            ref="multipleTable"
            :data="falseframeInfo"
            tooltip-effect="dark"
            style="width: 1100px;margin:0 auto"
            border
          >
            <el-table-column label="虚拟合同编号" align="center" prop="conOuterno"></el-table-column>
            <el-table-column label="虚拟合同名称" align="center" prop="conName"></el-table-column>
            <el-table-column label="所属框架合同编号" align="center" prop="parentNo"></el-table-column>
            <el-table-column label="所属框架合同名称" align="center" prop="fathName"></el-table-column>
            <el-table-column label="操作" width="200" align="center">
              <template slot-scope="scope">
                <div>
                  <el-button v-show="ms_roleName == 'ProjectClerk'" @click="$router.push({name:'buildPro',params: { conId: scope.row.conId,belongOrg:scope.row.belongOrg}})" type="text" size="small" class="red">添加项目</el-button>
                  <el-button v-show="ms_roleName == 'ProjectClerk'" type="text" size="small" class="red" @click="outputProject(scope.row.parentId,scope.row.conId)">导出项目</el-button>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="component-paging" v-if="falseframeInfo.length > 0">
          <div class="table-bottom">
            <div class="bottom-left"></div>
            <div class="paging">
              <div class="paging-left">
                <p>
                  共
                  <span>{{Math.ceil(addFalseContractsList.falseRowCount/addFalseContractsList.falsePageSize)}}</span> 页/
                  <span>{{addFalseContractsList.falseRowCount}}</span> 条数据
                </p>
              </div>
              <el-pagination
                background
                @size-change="SizeChange($event,getList,addFalseContractsList.falseCurrentPage,addFalseContractsList.falsePageSize)"
                @current-change="CurrentChange($event,getList,addFalseContractsList.falseCurrentPage,addFalseContractsList.falsePageSize)"
                :current-page.sync="addFalseContractsList.falseCurrentPage"
                :page-sizes="[10, 20, 30]"
                :page-size.sync="addFalseContractsList.falsePageSize"
                layout="sizes, prev, pager, next, jumper"
                :total="addFalseContractsList.falseRowCount"
              ></el-pagination>
            </div>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane :label="'单项合同（'+singleCount+'）'" name="second">
        <div class="component-searchHeader">
          <div class="search-header">
            <div class="left-title">
              <p class="left-text">
                <span class="iconfont" style="font-weight:700">&#xe63d;</span>筛选查询
              </p>
              <div class="right">
                <button @click="singlePage.singleCurrentPage=1;getList()">查询</button>
              </div>
            </div>
          </div>
        </div>

        <div class="component-search-box">
          <el-form :inline="true" :model="singleSearch" class="demo-form-inline">
            <el-form-item label="输入搜索：" clearable>
              <el-input v-model="singleSearch.name" placeholder="合同名称/合同内部编号" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <span class="demonstration">签约时间：</span>
              <el-date-picker
                v-model="singleSearch.date"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="timestamp"
              ></el-date-picker>
            </el-form-item>
            <el-form-item label="合同类型：">
              <el-select v-model="singleSearch.type" placeholder="请选择单项合同类型" clearable>
                <el-option label="单项合同" value="4"></el-option>
                <!--<el-option label="虚拟单项合同" value="2"></el-option>-->
                <el-option label="框架子单项合同" value="3"></el-option>
              </el-select>
            </el-form-item>

            <el-form-item
              label="项目部："
              v-show="ms_roleName == 'CenterClerk' || ms_roleName == 'CenterDeputy' ||

           ms_roleName == 'CenterFinanceManager' || ms_roleName == 'CenterBOSS'"
            >
              <el-select v-model="singleSearch.beOrg" placeholder="请选择项目部" clearable>
                <el-option
                  v-for="(item, index) in list2"
                  :key="index"
                  :value="item.orgId"
                  :label="item.orgName"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>

        <div class="component-listHeader">
          <div class="search-header">
            <div class="left-title">
              <p class="left-text">
                <span class="iconfont">&#xe61e;</span>
                单项合同/虚拟单项合同列表
              </p>
              <div class="right">
                <button v-show="ms_roleName == 'ProjectClerk'" @click="addSingleContract">添加合同</button>
              </div>
            </div>
          </div>
        </div>

        <div class="table">
          <el-table
            ref="multipleTable"
            :data="singleInfo"
            tooltip-effect="dark"
            style="width: 1100px;margin:0 auto"
            border
          >
            <el-table-column
              :label="type?'单项合同号':'虚拟单项合同'"
              align="center"
              width="85"
              prop="conOuterno"
            ></el-table-column>
            <el-table-column label="合同内部号" align="center" width="100" prop="conInnerno"></el-table-column>

            <el-table-column label="所属框架合同号" align="center" width="105" prop="parentNo"></el-table-column>
            <el-table-column label="合同名称" align="center" prop="conName"></el-table-column>
            <el-table-column label="合同金额(万元)" align="center" width="105" prop="conMoney"></el-table-column>
            <el-table-column label="空余金额(万元)" align="center" width="105" prop="freeAmount"></el-table-column>
            <el-table-column label="签约时间" align="center" width="135" prop="signDate">
              <template slot-scope="scope">{{scope.row.signDate | timeFilter}}</template>
            </el-table-column>
            <el-table-column label="完工时间" align="center" width="135" prop="finishDate">
              <template slot-scope="scope">{{scope.row.finishDate | timeFilter}}</template>
            </el-table-column>
            <!-- <el-table-column label="负责人" align="center" width="70" prop="people"></el-table-column> -->
            <el-table-column label="操作" width="150" align="center">
              <template slot-scope="scope">
                <div>
                  <!-- {{scope.row}} -->
                  <el-button
                    @click="checkSingle(scope.row)"
                    type="text"
                    size="small"
                    class="red"
                  >查看/编辑</el-button>
                  <!-- <el-button
                    @click="deleteSingle(scope.$index, scope.row)"
                    type="text"
                    size="small"
                    class="red"
                  >删除</el-button>-->
                </div>
                <div>
                  <el-button
                    v-show="ms_roleName == 'ProjectClerk'"
                    @click="$router.push({name:'buildPro',params: { row: scope.row}})"
                    type="text"
                    size="small"
                    class="red"
                  >添加项目</el-button>
                  <el-button
                    v-show="ms_roleName == 'ProjectClerk' && scope.row.conType==3"
                    @click="importSingle(scope.row)"
                    type="text"
                    size="small"
                    class="red"
                  >导入项目</el-button>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="component-paging" v-if="singleInfo.length > 0">
          <div class="table-bottom">
            <div class="bottom-left"></div>
            <div class="paging">
              <div class="paging-left">
                <p>
                  共
                  <span>{{Math.ceil(singlePage.singleRowCount/singlePage.singlePageSize)}}</span> 页/
                  <span>{{singlePage.singleRowCount}}</span> 条数据
                </p>
              </div>
              <el-pagination
                background
                @size-change="SizeChange($event,getList,singlePage.singleCurrentPage,singlePage.singlePageSize)"
                @current-change="CurrentChange($event,getList,singlePage.singleCurrentPage,singlePage.singlePageSize)"
                :current-page.sync="singlePage.singleCurrentPage"
                :page-sizes="[10, 20, 30]"
                :page-size.sync="singlePage.singlePageSize"
                layout="sizes, prev, pager, next, jumper"
                :total="singlePage.singleRowCount"
              ></el-pagination>
            </div>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane :label="'分包合同（'+subCount+'）'" name="third">
        <div class="component-searchHeader">
          <div class="search-header">
            <div class="left-title">
              <p class="left-text">
                <span class="iconfont" style="font-weight:700">&#xe63d;</span>筛选查询
              </p>
              <div class="right">
                <button @click="subPage.subCurrentPage=1;getList()">查询</button>
              </div>
            </div>
          </div>
        </div>

        <div class="component-search-box">
          <el-form :inline="true" :model="subSearch" class="demo-form-inline">
            <el-form-item label="输入搜索：" clearable>
              <el-input v-model="subSearch.name" placeholder="合同名称/合同内部编号" clearable></el-input>
            </el-form-item>
            <el-form-item>
              <span class="demonstration">签约时间：</span>
              <el-date-picker
                v-model="subSearch.date"
                type="date"
                placeholder="选择日期"
                format="yyyy 年 MM 月 dd 日"
                value-format="timestamp"
              ></el-date-picker>
            </el-form-item>
            <el-form-item
              label="项目部："
              v-show="ms_roleName == 'CenterClerk' || ms_roleName == 'CenterDeputy' || ms_roleName == 'CenterFinanceManager' || ms_roleName == 'CenterBOSS'"
            >
              <el-select v-model="subSearch.beOrg" placeholder="请选择项目部" clearable>
                <el-option
                  v-for="(item, index) in list2"
                  :key="index"
                  :value="item.orgId"
                  :label="item.orgName"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>

        <div class="component-listHeader">
          <div class="search-header">
            <div class="left-title">
              <p class="left-text">
                <span class="iconfont">&#xe61e;</span>
                分包合同
              </p>
              <div class="right">
                <button v-show="ms_roleName == 'ProjectClerk'" @click="add3">添加合同</button>
              </div>
            </div>
          </div>
        </div>

        <div class="table">
          <el-table
            ref="multipleTable"
            :data="subInfo"
            tooltip-effect="dark"
            style="width: 1100px;margin:0 auto"
            border
          >
            <el-table-column label="分包合同号" align="center" width="85" prop="conOuterno"></el-table-column>
            <el-table-column label="合同内部号" align="center" width="120" prop="conInnerno"></el-table-column>
            <el-table-column label="所属合同号" align="center" width="105" prop="parentNo"></el-table-column>
            <el-table-column label="合同名称" align="center" prop="conName"></el-table-column>
            <el-table-column label="合同金额(万元)" align="center" width="110" prop="conMoney"></el-table-column>
            <el-table-column label="签约时间" align="center" width="140" prop="signDate">
              <template slot-scope="scope">{{scope.row.signDate | timeFilter}}</template>
            </el-table-column>
            <el-table-column label="完工时间" align="center" width="140" prop="finishDate">
              <template slot-scope="scope">{{scope.row.finishDate | timeFilter}}</template>
            </el-table-column>
            <!-- <el-table-column label="项目负责人" align="center" width="100" prop="people"></el-table-column> -->
            <el-table-column label="操作" width="200" align="center">
              <template slot-scope="scope">
                <div>
                  <el-button @click="checkSub(scope.row)" type="text" size="small" class="red">查看/编辑</el-button>
                </div>
                <div>
                  <el-button
                    v-show="ms_roleName == 'ProjectClerk'"
                    @click="$router.push({name:'buildPro',params: { row: scope.row}})"
                    type="text"
                    size="small"
                    class="red"
                  >添加项目</el-button>
                  <!-- <el-button
                    @click="deleteSub(scope.$index, scope.row)"
                    type="text"
                    size="small"
                    class="red"
                  >删除</el-button>-->
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="component-paging" v-if="subInfo.length > 0">
          <div class="table-bottom">
            <div class="bottom-left"></div>
            <div class="paging">
              <div class="paging-left">
                <p>
                  共
                  <span>{{Math.ceil(subPage.subRowCount/subPage.subPageSize)}}</span> 页/
                  <span>{{subPage.subRowCount}}</span> 条数据
                </p>
              </div>
              <el-pagination
                background
                @size-change="SizeChange($event,getList,subPage.subCurrentPage,subPage.subPageSize)"
                @current-change="CurrentChange($event,getList,subPage.subCurrentPage,subPage.subPageSize)"
                :current-page.sync="subPage.subCurrentPage"
                :page-sizes="[10, 20, 30]"
                :page-size.sync="subPage.subPageSize"
                layout="sizes, prev, pager, next, jumper"
                :total="subPage.subRowCount"
              ></el-pagination>
            </div>
          </div>
        </div>
      </el-tab-pane>
    </el-tabs>


    <!--导出弹框-->
    <div class="component-model">
      <el-dialog title="导出" :visible.sync="dialogVisible" width="600px">
        <div class="subFrame">
          <el-form>
            <el-form-item label="选择项目:" style="width: 430px;margin:0 auto 10px;" label-width="180px;">
              <el-select clearable v-model="belongSignleProject" placeholder="请选择要导出的项目" style="width: 300px;">
                <el-option
                  v-for="(item, index) in optionsLists"
                  :key="index"
                  :value.sync="item.proId"
                  :label.sync="item.proName"
                  ref="bgcc"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="选择所属单项合同:" style="width: 430px;margin:0 auto;" label-width="180px;">
              <el-select clearable v-model="belongSignleContract" placeholder="请选择所属单项合同" style="width: 300px;">
                <el-option
                  v-for="(item, index) in options"
                  :key="index"
                  :value.sync="item.conId"
                  :label.sync="item.conName"
                  ref="bgcc"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>

        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取消</el-button>
          <el-button @click="sure">确定</el-button>
        </span>
      </el-dialog>
    </div>


  </div>
</template>

<script>
import { log } from "util";
import ElForm from "../../../node_modules/element-ui/packages/form/src/form";
import ElFormItem from "../../../node_modules/element-ui/packages/form/src/form-item";
export default {
  components: {
    ElFormItem,
    ElForm},
  name: "contractList",
  data() {
    return {
      // 按钮权限根据角色控制是否显示
      ms_roleName: localStorage.getItem("roleName"),
      dialogVisible:false,//导出项目弹框
      options:[],//单项合同列表
      belongSignleContract:'',//所属单项合同
      name: "",
      // 框架合同列表
      frameInfo: [],
      //单项合同列表
      singleInfo: [],
      //分包合同列表
      subInfo: [],
      // tab切换显示默认第一栏
      activeName: "first",
      // 框架合同搜索
      frameSearch: {
        name: "",
        first: "",
        beOrg: ""
      },
      // 分包合同搜索
      singleSearch: {
        name: "",
        date: "",
        type: "",
        beOrg: ""
      },
      // 分包合同搜索
      subSearch: {
        name: "",
        date: "",
        beOrg: ""
      },
      type: true,
      //框架合同分页部分总条数，当前页，每页条数
      framePage: {
        frameRowCount: 0,
        frameCurrentPage: 1,
        framePageSize: 10
      },
      //虚拟合同分页
      addFalseContractsList:{
        name:'',
        falseRowCount: 0,
        falseCurrentPage: 1,
        falsePageSize: 10
      },
      //单项合同分页部分总条数，当前页，每页条数
      singlePage: {
        singleRowCount: 0,
        singleCurrentPage: 1,
        singlePageSize: 10
      },
      //分包合同分页部分总条数，当前页，每页条数
      subPage: {
        subRowCount: 0,
        subCurrentPage: 1,
        subPageSize: 10
      },
      // 总条数
      total: 0,
      // 框架合同总数
      frameCount: 0,
      // 单项合同总数
      singleCount: 0,
      // 分包合同总数
      subCount: 0,
      // 甲方列表
      list1: "",
      // 所属项目部
      list2: "",
      count1:0,
      count2:0,
      count3:0,
      falseframeInfo:[],
      falseContractNum:0,
      optionsLists:[],
      belongSignleProject:'',
    };
  },
  created() {
    // 获取合同列表
    this.getList();
    // 获取甲方名称
    this.getCompany();
    //获取项目部列表
    this.getOrg();
  },
  methods: {
    //点击导出项目按钮
    outputProject(val,n){
      this.xuProjectLists(val,n)
    },
    //虚拟项目列表
    xuProjectLists(val,n){
      let suCb = res => {
          this.optionsLists = res.data.data;
          console.log(res.data.data);
          this.chooseSingleContract(val);
        },
        req = {
          url: "/api/web/proContract/getProjectByvirtualNo",
          methods: "post",
          data: {conId:n},
          success: suCb
        };
      this.$https(req);
    },
    //选择需要导出的单项合同
    chooseSingleContract(val){
      let suCb = res =>{
        this.options = res.data.data;
        this.dialogVisible = true;
        console.log(res.data)
      }
      let palyParam = {
        url: "/api/web/proContract/getKjZdxInfo",
        methods:'post',
        data: {parentId:val},
        success: suCb,
      }
      this.$https(palyParam);
    },
    //确定导出项目
    sure(){
      let suCb = res =>{
        this.$msg("导出成功")
        this.dialogVisible = false;
        console.log(res.data)
      }
      let palyParam = {
        url: "/api/web/proContract/exportProject",
        methods:'post',
        data: {proId:this.belongSignleProject,conId:this.belongSignleContract},
        success: suCb,
      }
      this.$https(palyParam)
    },
    // 刷新按钮刷新页面
    reverse() {
      this.$router.go(0);
    },
    //获取甲方类型
    getOrg() {
      let that = this,
        suCb = res => {
          console.log("获取的甲方类型", res.data);
          that.list2 = res.data.data;
        },
        erCb = res => {
          console.log(res);
        },
        req = {
          url: "/api/web/proProject/getProList",
          methods: "post",
          data: {},
          success: suCb,
          error: erCb
        };
      that.$https(req);
    },
    //标签页切换
    handleClick(tab, event) {
      this.getList();
      //  清空搜索框的值
      this.frameSearch.name = "";
      this.singleSearch.name = "";
      this.subSearch.name = "";
      // this.conType = [];
      this.frameSearch.first = "";
      this.singleSearch.date = "";
      this.subSearch.date = "";
      this.frameSearch.beOrg = "";
      this.singleSearch.beOrg = "";
      this.subSearch.beOrg = "";
    },

    // 获取甲方公司名称
    getCompany() {
      let that = this,
        suCb = res => {
          console.log("获取甲方公司名称：", res.data);
          that.list1 = res.data.data;
        },
        erCb = res => {
          console.log(res);
        },
        req = {
          url: "/api/web/proContract/getPartya",
          methods: "post",
          data: {},
          success: suCb,
          error: erCb
        };
      that.$https(req);
    },
    // 获取合同列表
    getList() {
      let that = this,
        params = {};
      switch (this.activeName) {
        case "first":
          params = {
            signDate: "",
            info: that.frameSearch.name,
            conPartya: that.frameSearch.first, // 甲方
            pageCurrent: that.framePage.frameCurrentPage,
            pageSize: that.framePage.framePageSize,
            conType: ["1"],
            belongOrg: that.frameSearch.beOrg
          };
          break;
        case "fourth":
          params = {
            signDate: "",
            info: that.addFalseContractsList.name,
            conPartya: '', // 甲方
            pageCurrent: that.addFalseContractsList.falseCurrentPage,
            pageSize: that.addFalseContractsList.falsePageSize,
            conType: ["2"],
            belongOrg: ''
          };
          break;
        case "second":
          let arr = [];
          arr.push(that.singleSearch.type);
          params = {
            signDate:
              that.singleSearch.date === null
                ? ""
                : that.singleSearch.date + "",
            info: that.singleSearch.name,
            conPartya: "",
            pageCurrent: that.singlePage.singleCurrentPage,
            pageSize: that.singlePage.singlePageSize,
            conType: arr == "" ? ["3", "4"] : arr,
            belongOrg: that.singleSearch.beOrg
          };
          break;
        case "third":
          params = {
            signDate:
              that.subSearch.date === null ? "" : that.subSearch.date + "",
            info: that.subSearch.name,
            conPartya: "",
            pageCurrent: that.subPage.subCurrentPage,
            pageSize: that.subPage.subPageSize,
            conType: ["5"],
            belongOrg: that.subSearch.beOrg
          };
          break;
      }
      let suCb = res => {
          console.log("合同列表查询结果", res);
          switch (this.activeName) {
            case "first":
              that.frameInfo = that.deepClone(res.data.list);
              that.framePage.frameRowCount = res.data.rowCount;
              // that.conType = "1";
              break;
            case "fourth":
              that.falseframeInfo = that.deepClone(res.data.list);
              that.addFalseContractsList.falseRowCount = res.data.rowCount;
              break;
            case "second":
              that.singleInfo = that.deepClone(res.data.list);
              that.singlePage.singleRowCount = res.data.rowCount;
              // that.conType = "3";
              break;
            case "third":
              that.subInfo = that.deepClone(res.data.list);
              that.subPage.subRowCount = res.data.rowCount;
              // that.conType = "5";
              break;
          }

          //将获得的合同数量显示在tab切换中
          if(res.data.contractNum.length > 0){
            for (let i in res.data.contractNum) {
           /* else if (res.data.contractNum[i].conType == "2") {
                that.count1 = parseInt(res.data.contractNum[i].num);
              }*/
              if (res.data.contractNum[i].conType == "1") {
                that.frameCount = res.data.contractNum[i].num;
              }else if (res.data.contractNum[i].conType == "2") {
               that.falseContractNum = parseInt(res.data.contractNum[i].num);
               } else if (res.data.contractNum[i].conType == "3") {
                that.count2 = parseInt(res.data.contractNum[i].num);
              } else if (res.data.contractNum[i].conType == "4") {
                that.count3 = parseInt(res.data.contractNum[i].num);
              } else if (res.data.contractNum[i].conType == "5") {
                that.subCount = res.data.contractNum[i].num;
              }
              that.singleCount = that.count1+that.count2+that.count3;
            }
          }
         /* console.log(
            "框架:",
            that.frameCount,
            "单项:",
            that.singleCount,
            "分包:",
            that.subCount
          );*/
        },
        erCb = res => {
          console.log(res);
        },
        req = {
          url: "/api/web/proContract/getAllContract",
          methods: "post",
          data: params,
          success: suCb,
          error: erCb
        };
//      console.log("合同列表查询参数：", req.data);
      that.$https(req);
    },
    //框架合同-查看编辑
    handleCheck(row) {
      console.log(row)
      this.$router.push({
        name: "detailframe",
        query: { row: row.conId,belongOrg:row.belongOrg }
      });
    },
    //框架合同-添加子合同
    handleAdd(row) {
      console.log(row);
      this.$router.push({
        name: "addTurecontract",
        params: {
          userTruename: row.conName,
          userOrg: row.conOuterno,
          partya: row.partya,
          partyb: row.partyb,
          conIds: row.conId,
          point: row.conDroppoint,
          conId: this.$md5(new Date().getTime().toString())
        }
      });
    },
    //框架合同-删除
    handleDelete() {},
    // 传过去本行数据 的 合同id    row.conId
    checkSingle(row) {
      this.$router.push({
        name: "detailsingle",
        query: {
          row: row.conId,
          rows: row.parentId,
          conType: row.conType
        }
      });
    },
    //单项合同-导入项目
    importSingle(row) {
      this.$router.push({
        name: "toLeadPro",
        query: {
          rows: row.parentId,
          freeAmount: row.freeAmount,
          conId: row.conId
        }
      });
    },
    //分包合同-查看编辑
    checkSub(row) {
      this.$router.push({
        name: "detailsub",
        query: {
          row: row.conId,
          rows: row.parentId
        }
      });
    },
    //分包合同-添加项目
    addSub(row) {
      console.log(row);
      this.$router.push({
        name: "buildPro",
        params: { row: row }
      });
    },
    //分包合同-删除
    deleteSub() {},
    // 添加框架合同
    add1() {
      //  把甲方的数据传过去
      this.$router.push({
        name: "addFra",
        params: {
          list1: this.list1,
          conId: this.$md5(new Date().getTime().toString())
        }
      });
    },
    // 虚拟合同 添加合同
    addFalseContractList() {
      this.$router.push({
        name: "addFalseFra",
        params: {
          conId: this.$md5(new Date().getTime().toString())
        }
      });
    },
    // 单项合同 添加合同
    addSingleContract() {
      this.$router.push({
        name: "addFalsecontract",
        params: {
          conId: this.$md5(new Date().getTime().toString())
        }
      });
    },
    //分包合同 添加合同 发送请求获取框架合同id
    add3() {
        this.$router.push({
          name: "subContract",
          params: {
            conId: this.$md5(new Date().getTime().toString())
          }
        });
    }
  }
};
</script>

<style scoped>
  .subFrame {
    overflow: hidden;
  }
  .subFrame span {
    display: inline-block;
    width: 100px;
    height: 38px;
    line-height: 38px;
    text-align: center;
    border: 1px solid #e4e4e4;
    margin-right: 40px;
    border-radius: 4px;
  }
  .subFrame span:last-of-type {
    margin-right: 0;
  }
.component-contractList .tabs-header {
  width: 1150px;
  box-sizing: border-box;
  margin: 20px auto 0;
}

.component-searchHeader .search-header {
  width: 1100px;
  box-sizing: border-box;
  border: 1px solid rgba(228, 228, 228, 1);
  background-color: rgba(255, 255, 255, 1);
  margin: 20px auto 0;
}

.component-searchHeader .search-header .left-title {
  display: flex;
  justify-content: space-between;
  width: 100%;
  background-color: rgba(243, 243, 243, 1);
  height: 45px;
  box-sizing: border-box;
}

.component-searchHeader .search-header .left-title .left-text {
  width: 20%;
  color: #666;
  line-height: 45px;
  font-family: "微软雅黑";
  font-weight: 400;
  font-size: 12px;
  text-align: left;
  margin: 0 0 0 30px;
}

.component-searchHeader .right {
  width: 70%;
  display: flex;
  justify-content: flex-end;
  margin-right: 30px;
}

.component-searchHeader .right button {
  padding: 0 25px;
  height: 30px;
  margin: 8px 5px;
  line-height: 30px;
  font-size: 14px;
  color: #666;
  background-color: #fff;
  border: 1px solid #ccc;
}

.component-searchHeader .right button:hover {
  background-color: #f3f3f3;
  cursor: pointer;
}
.component-search-box {
  width: 1100px;
  box-sizing: border-box;
  background-color: #fff;
  border: 1px solid #e4e4e4;
  border-top: none;
  margin: 0 auto;
  text-align: left;
  padding-left: 30px;
  line-height: 60px;
  padding-bottom: 15px;
  padding-top: 15px;
}
.component-search-box .el-input__inner {
  height: 35px;
  display: inline-block;
}
.el-form-item {
  margin-bottom: 0;
}
.component-listHeader .search-header {
  width: 1100px;
  box-sizing: border-box;
  border: 1px solid rgba(228, 228, 228, 1);
  border-bottom: none;
  background-color: rgba(255, 255, 255, 1);
  margin: 20px auto 0;
}

.component-listHeader .search-header .left-title {
  display: flex;
  justify-content: space-between;
  width: 100%;
  background-color: rgba(243, 243, 243, 1);
  height: 45px;
  box-sizing: border-box;
}

.component-listHeader .search-header .left-title .left-text {
  width: 20%;
  color: #666;
  line-height: 45px;
  font-family: "微软雅黑";
  font-weight: 400;
  font-size: 12px;
  text-align: left;
  margin: 0 0 0 30px;
}

.component-listHeader .search-header .right {
  width: 70%;
  display: flex;
  justify-content: flex-end;
  margin-right: 10px;
}

.component-listHeader .search-header .right button {
  padding: 0 15px;
  height: 30px;
  width: 110px;
  margin: 6px 5px;
  line-height: 30px;
  font-size: 14px;
  color: #1abc9c;
  background-color: #fff;
  border: 1px solid #ccc;
}
.el-form-item {
  text-align: right;
  /*width: 310px;*/
}
.component-listHeader .search-header .right button:hover {
  background-color: #1abc9c;
  color: #fff;
  cursor: pointer;
}
.component-listHeader .search-header .right .right-select-margin {
  margin-top: 8px;
  margin-right: 8px;
}
/* 删除按钮 */
.red {
  color: #48c9b0;
  font-size: 12px;
}
</style>
